<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="root">
        <h1>{{name}}</h1>
        <hr>
        <!-- 第三步：使用组件 -->
        <hello></hello>  
        <hr>
        <my-school></my-school>
        <hr>
        <student></student>
    </div>
    <div id="root2">
        <hello></hello>
    </div>

    <script>

        // 定义全局组件
        const hello = Vue.extend({
            template: `<h3>hello</h3>`,
        })
        Vue.component('hello', hello)

        new Vue({
            el: '#root2'
        })

        // 第一步：定义组件
        const school = Vue.extend({
            template: `
                <div>
                    <h2>{{schoolName}}</h2>
                    <h2>{{schoolAddress}}</h2>
                </div>
            `,
            data() {
                return {
                    schoolName: '尚硅谷',
                    schoolAddress: 'bejing',
                }
            }
        })

        const student = Vue.extend({
            template: `
                <div>
                    <h2>{{studentName}}</h2>
                    <h2>{{studentAge}}</h2>
                </div>
            `,
            data() {
                return {
                    studentName: 'zoe',
                    studentAge: '18',
                }
            }
        })



        new Vue({
            el: '#root',
            data: {
                name: '非单文件组件-基本使用'
            },
            components: {
                "my-school": school,   // 第二步：注册组件
                student,
            }
        })
    </script>
</body>
</html>